package main

import (
	"cp/cboard"
	"cp/theme"
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/driver/desktop"
	"fyne.io/fyne/v2/widget"
	"log"
)

func main() {
	myapp := app.New()
	setTheme2(myapp)
	myWindow := myapp.NewWindow("复制")
	myWindow.Resize(fyne.NewSize(80, 200))

	if desk, ok := myapp.(desktop.App); ok {
		m := fyne.NewMenu("MyApp",
			fyne.NewMenuItem("Show", func() {
				log.Println("Tapped show")
			}))
		desk.SetSystemTrayMenu(m)
	}

	data := binding.BindStringList(
		&[]string{},
	)

	go cboard.Do(data)

	list := widget.NewListWithData(data,
		func() fyne.CanvasObject {
			return widget.NewLabel("template")
		},
		func(i binding.DataItem, o fyne.CanvasObject) {
			o.(*widget.Label).Bind(i.(binding.String))
		})

	myWindow.SetContent(list)

	myWindow.Show()
	myapp.Run()
}

func setTheme1(app fyne.App) {
	t := &theme.MyTheme{}
	app.Settings().SetTheme(t)
}
func setTheme2(app fyne.App) {
	t := &theme.MyTheme2{}
	t.SetFonts("./resource/font/Consolas-with-Yahei Regular Nerd Font.ttf", "")

	app.Settings().SetTheme(t)
}
